package com.alks.function.controller.stockdept.pcfactorystockquery;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.stockdept.pcfactorystockwork.CsmDetAddRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.CsmDetRequest;
import com.alks.function.data.request.stockdept.pcfactorystockwork.CsmMtlAddRequest;
import com.alks.function.service.stockdept.pcfactorystockquery.IConsumInService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;

@RestController
@ApiRestController("/pcFactorStockQuery")
@Api(value = "仓储部查询",tags = "仓储部-仓储工厂作业-耗品入库作业")
@RequiredArgsConstructor
@RoleCheck(prgIds = {"100412","150209","160210","170509","180710"})
public class ConsumInController {

    @Autowired
    IConsumInService service;

    @GetMapping("/getCsmInTempQuery")
    @ApiOperation(value = "耗品入库作业-待出剩料明细-查询",tags = "仓储部-仓储工厂作业-耗品入库作业")
    public ResponseInfo getCsmInTempQuery(){
        return service.getCsmInTempQuery();
    }

    @PostMapping("/csmMtlNoCreat")
    @ApiOperation(value = "耗品入库作业-耗品物料ID生成-查询",tags = "仓储部-仓储工厂作业-耗品入库作业")
    public ResponseInfo csmMtlNoCreat(@RequestParam@ApiParam("分类ID") String mtlTypeNo){
        return service.csmMtlNoCreat(mtlTypeNo);
    }

    @PutMapping("/csmMtlCreat")
    @ApiOperation(value = "耗品入库作业-耗品建档-新增",tags = "仓储部-仓储工厂作业-耗品入库作业")
    public ResponseInfo csmMtlCreat(@RequestBody CsmMtlAddRequest request){
        return service.csmMtlCreat(request);
    }

    @PostMapping("/csmMtlDelete")
    @ApiOperation(value = "耗品入库作业-耗品删除-删除",tags = "仓储部-仓储工厂作业-耗品入库作业")
    public ResponseInfo csmMtlDelete(@RequestParam@ApiParam("物料ID") String mtlNo){
        return service.csmMtlDelete(mtlNo);
    }

    @PostMapping("/csmInTempAdd")
    @ApiOperation(value = "耗品入库作业-插入待入库耗品-新增",tags = "仓储部-仓储工厂作业-耗品入库作业")
    public ResponseInfo csmInTempAdd(@RequestParam@ApiParam("物料ID") String mtlNo){
        return service.csmInTempAdd(mtlNo);
    }

    @PostMapping("/csmInTempUpdate")
    @ApiOperation(value = "耗品入库作业-待入库明细修改-更新",tags = "仓储部-仓储工厂作业-耗品入库作业")
    public ResponseInfo csmInTempUpdate(@RequestParam@ApiParam("物料ID") String mtlNo,
                                        @RequestParam(required = false)@ApiParam("数量") BigDecimal qty,
                                        @RequestParam(required = false)@ApiParam("备注") String remark){
        return service.csmInTempUpdate(mtlNo,qty,remark);
    }

    @PostMapping("/csmInTempDelete")
    @ApiOperation(value = "耗品入库作业-待入库耗品删除-删除",tags = "仓储部-仓储工厂作业-耗品入库作业")
    public ResponseInfo csmInTempDelete(@RequestParam@ApiParam("物料ID") String mtlNo){
        return service.csmInTempDelete(mtlNo);
    }

    @PutMapping("/getCsmInDetailQuery")
    @ApiOperation(value = "耗品入库作业-入库明细资料查询-查询",tags = "仓储部-仓储工厂作业-耗品入库作业")
    public ResponseInfo getCsmInDetailQuery(@RequestBody CsmDetRequest request){
        return ResponseInfo.ok(service.getCsmInDetailQuery(request));
    }

    @PutMapping("/csmInDetailAdd")
    @ApiOperation(value = "耗品入库作业-入库批处理-新增",tags = "仓储部-仓储工厂作业-耗品入库作业")
    public ResponseInfo csmInDetailAdd(@RequestBody CsmDetAddRequest request){
        return service.csmInDetailAdd(request);
    }

    @PostMapping("/csmInDetailDelete")
    @ApiOperation(value = "耗品入库作业-耗品明细删除-删除",tags = "仓储部-仓储工厂作业-耗品入库作业")
    public ResponseInfo csmInDetailDelete(@RequestParam@ApiParam("物料ID") String mtlNo,
                                          @RequestParam@ApiParam("入库单号") String slipNo){
        return service.csmInDetailDelete(mtlNo,slipNo);
    }
}
